package com.designpattern.demo.design2;

/**
 * 返利收费子类
 * Created by lingchen on 2019/11/26. 21:03
 * mail:lingchen52@foxmail.com
 */
public class CashReturn extends CashSuper {

    private double moneyCondition = 0.0d;
    private double moneyReturn = 0.0d;

    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public double acceptCash(double money) {
        double result = money;
        if (money >= moneyCondition) {
            result = money - ((int) (money / moneyCondition)) * moneyReturn;
        }
        return result;
    }
}
